<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <!--<base href="//webapi.amap.com/ui/1.0/ui/misc/PathSimplifier/examples/"/>-->
    <meta charset="utf-8">
    <link rel="shortcut icon" href="/images/favicon/favicon.ico"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>简单路径</title>
    <style>
        html,
        body,
        #container {
            width: 100%;
            height: 100%;
            margin: 0px;
        }
    </style>
    <link rel="stylesheet" href="/css/layui.css">
</head>

<body>
<div style="width: 1200px; margin: 0 auto;">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">

            <ul class="layui-nav">
                <li class="layui-nav-item"><a href="">历史轨迹查看</a></li>
                <li class="layui-nav-item"><a href="">实时定位查看</a></li>

            </ul>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        <img src="http://47.94.10.67/images/jobc212c90f-564d-456e-9308-7a5f2f6751b7.jpg" class="layui-nav-img">
                        侯瑞阳
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="">基本资料</a></dd>
                        <dd><a href="">安全设置</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="/user/logout">退出</a></li>
            </ul>
        </div>

    </div>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>日期范围选择</legend>
    </fieldset>
    <div class="layui-form">
        <form action="" id="dateForm">
            <div class="layui-form-item ">
                <div class="layui-inline ">
                    <label class="layui-form-label">日期范围</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="dateRange" placeholder=" - ">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin" lay-submit="" lay-filter="date-range-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </form>
    </div>

    <div id="container" style="height: 600px;width: 1200px;">

    </div>


</div>
<script src="/layui.js"></script>
<script type="text/javascript" src='//webapi.amap.com/maps?v=1.4.14&key=0aeec87c9a9abc1a2b28537edefe1863'></script>
<!-- UI组件库 1.0 -->
<script src="//webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
<script type="text/javascript" src="/layui.js"></script>
<script>
    //创建地图
    var map = new AMap.Map('container', {
        zoom: 4
    });
    AMapUI.load(['ui/misc/PathSimplifier', 'lib/$'], function (PathSimplifier, $) {
        if (!PathSimplifier.supportCanvas) {
            alert('当前环境不支持 Canvas！');
            return;
        }
        var pathSimplifierIns = new PathSimplifier({
            zIndex: 100,
            map: map, //所属的地图实例
            getPath: function (pathData, pathIndex) {
                //设置数据
                return pathData.path;
            },
            getHoverTitle: function (pathData, pathIndex, pointIndex) {
                if (pointIndex >= 0) {
                    return pathData.name + '，点：' + pointIndex + '/' + pathData.path.length;
                }
                return pathData.name + '，点数量' + pathData.path.length;
            },
            renderOptions: {
                renderAllPointsIfNumberBelow: -1 //绘制路线节点，如不需要可设置为-1
            }
        });
        window.pathSimplifierIns = pathSimplifierIns;
        $.ajax({
            type: "GET",
            url: '/getGpsData',
            success: function (result) {
                console.log(result);
                pathSimplifierIns.setData(result.data[1]);
                AMapUI.loadUI(['overlay/SimpleMarker'], function (SimpleMarker) {

                    var position = result.data[0][0].list;
                    var iconLabel = result.data[0][0].iconLabel;
                    var iconStyle = result.data[0][0].iconStyle;

                    var position1 = result.data[0][1].list;
                    var iconLabel1 = result.data[0][1].iconLabel;
                    var iconStyle1 = result.data[0][1].iconStyle;

                    // 设置开始点图标样式
                    new SimpleMarker({
                        //设置节点属性
                        iconLabel: iconLabel,
                        iconStyle: iconStyle,
                        map: map,
                        position: position
                    });
                    // 设置结束点图标样式
                    new SimpleMarker({
                        //设置节点属性
                        iconLabel: iconLabel1,
                        iconStyle: iconStyle1,
                        map: map,
                        position: position1
                    });

                });
            }
        });
    });


    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use(['element', 'laydate', 'form'], function () {
        var element = layui.element;
        var laydate = layui.laydate;
        var form = layui.form;
        var $ = layui.$;
        //日期范围
        laydate.render({
            elem: '#dateRange'
            , range: true
            ,format: 'yyyy/MM/dd'
            ,max: 0
        });
        //监听提交
        form.on('submit(date-range-search)', function (data) {
            layer.msg($("#dateRange").val());
            // layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
</script>
</body>

</html>